package com.javasea.spring.starter.config;

import com.javasea.spring.starter.properties.DeptProperties;
import com.javasea.spring.starter.properties.TestC;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 *@ClassName DefaultImportBeanDefinitionRegister
 *@Description TODO
 *@Author longxiaonan@163.com
 *@Date 2022/5/1 0001 18:02
 */
public class DefaultImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
    /**
     * 在这个方法内将bean添加到bean容器中
     * @param annotationMetadata
     * @param registry
     */
    @Override
    public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry){
        RootBeanDefinition rootDefinition1 = new RootBeanDefinition(DeptProperties.class);
        RootBeanDefinition rootDefinition2 = new RootBeanDefinition(TestC.class);
        // 添加时指定bean名称
        registry.registerBeanDefinition("deptInstance", rootDefinition1);
        registry.registerBeanDefinition("testcInstance", rootDefinition2);
    }
}
